﻿'
' Will Strohl (will.strohl@gmail.com)
' http://www.willstrohl.com
' http://dnntweet.codeplex.com
'
' Copyright (c) 2011, Will Strohl
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this 
' software and associated documentation files (the "Software"), to deal in the Software 
' without restriction, including without limitation the rights to use, copy, modify, 
' merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 
' permit persons to whom the Software is furnished to do so, subject to the following 
' conditions:
'
' The above copyright notice and this permission notice shall be included in all copies 
' or substantial portions of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
' INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
' PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
' HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
' OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'

Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions

Imports WillStrohl.Modules.Twitter.SearchHistoryInfoMembers

Namespace WillStrohl.Modules.Twitter

    <Serializable()> _
    Public NotInheritable Class SearchHistoryInfo
        Implements ISearchHistoryInfo, IHydratable

#Region " Private Members "

        Private p_SearchId As Integer = Null.NullInteger
        Private p_ModuleId As Integer = Null.NullInteger
        Private p_UserId As Integer = Null.NullInteger
        Private p_SearchText As String = Null.NullString

#End Region

#Region " Public Properties "

        Public Property SearchId() As Integer Implements ISearchHistoryInfo.SearchId
            Get
                Return Me.p_SearchId
            End Get
            Set(ByVal value As Integer)
                Me.p_SearchId = value
            End Set
        End Property

        Public Property ModuleId() As Integer Implements ISearchHistoryInfo.ModuleId
            Get
                Return Me.p_ModuleId
            End Get
            Set(ByVal value As Integer)
                Me.p_ModuleId = value
            End Set
        End Property

        Public Property UserId() As Integer Implements ISearchHistoryInfo.UserId
            Get
                Return Me.p_UserId
            End Get
            Set(ByVal value As Integer)
                Me.p_UserId = value
            End Set
        End Property

        Public Property SearchText() As String Implements ISearchHistoryInfo.SearchText
            Get
                Return Me.p_SearchText
            End Get
            Set(ByVal value As String)
                Me.p_SearchText = value
            End Set
        End Property

#End Region

#Region " Constructors "

        Public Sub New()
            ' do nothing
        End Sub

        Public Sub New(ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal SearchText As String)
            Me.p_ModuleId = ModuleId
            Me.p_UserId = UserId
            Me.p_SearchText = SearchText
        End Sub

        Public Sub New(ByVal SearchId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer, ByVal SearchText As String)
            Me.p_SearchId = SearchId
            Me.p_ModuleId = ModuleId
            Me.p_UserId = UserId
            Me.p_SearchText = SearchText
        End Sub

#End Region

#Region " IHydratable Implementation "

        Public Property KeyID() As Integer Implements DotNetNuke.Entities.Modules.IHydratable.KeyID
            Get
                Return Me.p_SearchId
            End Get
            Set(ByVal value As Integer)
                Me.p_SearchId = value
            End Set
        End Property

        Public Sub Fill(ByVal dr As System.Data.IDataReader) Implements DotNetNuke.Entities.Modules.IHydratable.Fill
            Try
                While dr.Read
                    If Not dr.Item(SearchIdField) Is Nothing Then
                        Me.p_SearchId = Integer.Parse(dr.Item(SearchIdField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(ModuleIdField) Is Nothing Then
                        Me.p_ModuleId = Integer.Parse(dr.Item(ModuleIdField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(UserIdField) Is Nothing Then
                        Me.p_UserId = Integer.Parse(dr.Item(UserIdField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(SearchTextField) Is Nothing Then
                        Me.p_SearchText = dr.Item(SearchTextField).ToString
                    End If
                End While
            Catch ex As Exception
                LogException(ex)
            Finally
                If Not dr.IsClosed Then
                    dr.Close()
                End If
            End Try
        End Sub

#End Region

    End Class

End Namespace